(function () {
    getData()

    function getData() {
        //根据search解析？后面内容
        let productid = location.search.slice(1).split("=")[1];
        $.ajax({
            url: "http://chst.vip:1234/api/getdiscountproduct?",
            data: {
                productid: productid
            }
        }).then(res => {
            createContent(res.result)
        })
    }

    function createContent(data) {
        let html = data.reduce((value, item) => {
            return value += `
                <h4>${item.productName}</h4>
                <div class="other">
                    <span>${item.productFrom}&nbsp;丨&nbsp;${item.productTime}</span>
                    <i>${item.productTips}</i>
                    <p>${item.productPrice}</p>
                </div>
                <div class="info">${item.productInfo}</div>
                <div class="img">${item.productImg}</div>
            `
        }, '')
        $("main .res").html(html)
        let txt = data.reduce((value, item) => {
            return value += `
            ${item.productComment}
            `
        }, '')
        $("main .liuyan").html(txt)
    }
    //返回顶部动漫效果
    $("footer>.nav li").eq(2).click(function () {
        $("html").stop().animate({
            scrollTop: 0
        }, 200)
    })
}())